home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 102 / examples / linedemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-25  |  3.6 KB  |  90 lines

  1. /* ATARI Explorer, Dec'86 ,for MWC */
  2. #include <stdio.h>
  3. #include <gemdefs.h>
  4. #include <osbind.h>
  5.  
  6. /* global control arrays for VDI */
  7. int contrl[12];
  8. int intin[128];
  9. int ptsin[128];
  10. int intout[128];
  11. int ptsout[128];
  12.  
  13. /*Global variables for application*/
  14. int handle, dummy, xres,yres;
  15. int work_in[11], work_out[57];
  16.  
  17. main()
  18. {
  19.         int   i;
  20.         char ch;
  21.         for ( i = 0 ; i < 10 ; work_in[i++] = 1 );
  22.         work_in[10] = 2 ;     /* swiss font */
  23.         appl_init() ;
  24.         handle = graf_handle( &dummy, &dummy, &dummy, &dummy );
  25.         /*VOID*/ v_opnvwk(work_in,&handle,work_out);
  26.         xres   = work_out[0];         /* open vir.wrk.station       */
  27.         yres   = work_out[1];
  28.         /*VOID*/ v_hide_c(handle);    /* hide mouse                 */
  29.         do                            /* line drawing demonstration */
  30.         {
  31.                 linedemo();
  32.                 while ( ! Bconstat (2));
  33.         }
  34.         while (( ch = Bconin(2)) != '\33');
  35.         printf("\33E\33e\n");         /* clears screen, homes & shows cursor */
  36.         v_show_c(handle);             /* shows mouse                */
  37.         v_clsvwk(handle);             /* closes virtual workstation */
  38.         appl_exit();                  /* exits application          */
  39. }
  40. linedemo()                  /* Function: Perform line Demonstration */
  41. {
  42.         int pxyarray[4], rgb_in[3];
  43.         int style, width, beg_style, end_style;
  44.                                       /* Clear screen, home and show cursor */
  45.         printf(" \33E\33e\n ");
  46.         printf("1 =  solid     \n 2 = long dash  \n 3 = dot         \n");
  47.         printf(" 4 = dash dot   \n 5 = dash       \n 6 = dash dot dot\n\n" );
  48.         printf(" Enter line style< 1 - 7 >: " );
  49.         scanf ( "%d" , &style );
  50.         vsl_type ( handle , style );
  51.         printf(" \n\n Enter line width< 1 - n/2 pixels>: " );
  52.         scanf ( "%d" , &width );
  53.         vsl_width( handle , width );
  54.         printf(" \n\n0 = squared\n1 = arrow\n2 = rounded\n\n " );
  55.         printf(" Enter first line end style<0,1,2>: " ) ;
  56.         scanf ( "%d" , &beg_style ) ;
  57.         printf(" \nEnter second line end style<0,1,2>1:    \n");
  58.         scanf ( "%d" , &end_style ) ;
  59.         vsl_ends(handle,beg_style,end_style ) ;
  60.         printf(" Enter 3 color variables(red,grn,blu). \n" ) ;
  61.         printf(" Each may range from 1 to 1000.      \n\n" ) ;
  62.         printf(" \n Enter  RED  Value: " ) ;
  63.         scanf ( "%d" , &rgb_in[0] ) ;
  64.         printf(" \n Enter GREEN Value: " ) ;
  65.         scanf ( "%d" , &rgb_in[1] ) ;
  66.         printf(" \n Enter  BLUE Value: " ) ;
  67.         scanf ( "%d" , &rgb_in[2] ) ;
  68.         vs_color(handle,2,rgb_in);
  69.         vsl_color(handle,2);
  70.                       /* Get Coordinates */
  71.         printf( "\n\n Enter X-coordinate of starting point. \n" ) ;
  72.         printf("  (May range from 0 - %d): ",xres ) ;
  73.         scanf ( "%d" , &pxyarray[0] ) ;
  74.         printf( "\n\n Enter Y-coordinate of starting point. \n" ) ;
  75.         printf("  (May range from 0 - %d): ",yres ) ;
  76.         scanf ( "%d" , &pxyarray[1] ) ;
  77.         printf( "\n\n Enter X-coordinate of  ending  point. \n" ) ;
  78.         printf("  (May range from 0 - %d): ",xres ) ;
  79.         scanf ( "%d" , &pxyarray[2] ) ;
  80.         printf( "\n\n Enter Y-coordinate of  ending  point. \n" ) ;
  81.         printf("  (May range from 0 - %d): ",yres ) ;
  82.         scanf ( "%d" , &pxyarray[3] ) ;
  83.                       /* Clear screen, home and hide cursor */
  84.         printf( "\33E\33f\n" ) ;
  85.                       /*            DRAW    LINE            */
  86.         v_pline(handle,2,pxyarray);
  87. }
  88.  
  89. /* Then blow them away with the PGG Listing 3.6 page171:  */
  90.